package com.czy.owner.api;


import com.czy.owner.db.UserHelper;
import com.czy.owner.global.Constants;
import com.czy.owner.net.api.BaseApi;
import com.czy.owner.net.listener.HttpOnNextListener;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;
import java.util.HashMap;
import retrofit2.Retrofit;
import rx.Observable;

/**
 * Created by asus on 2017/6/1.
 */

public class StoreSearchApi  extends BaseApi {

    private String likeName;
    private String gprsX;
    private String gprsY;
    private String page;
    private String size;

    public String getLikeName() {
        return likeName;
    }

    public String getPage() {
        return page;
    }

    public String getSize() {
        return size;
    }

    public String getGprsX() {
        return gprsX;
    }

    public void setGprsX(String gprsX) {
        this.gprsX = gprsX;
    }

    public String getGprsY() {
        return gprsY;
    }

    public void setGprsY(String gprsY) {
        this.gprsY = gprsY;
    }

    public void setLikeName(String likeName) {
        this.likeName = likeName;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public StoreSearchApi(HttpOnNextListener listener, RxAppCompatActivity rxAppCompatActivity) {
        super(listener, rxAppCompatActivity);
        setShowProgress(false);
        setCache(true);
        setMothed(UserHelper.getInstance().getUserAccount() + Constants.OWN_SEARCHSTORES);//相当于缓存保存的Key
        setCookieNetWorkTime(0);//有网缓存0s,在0s内点击无效
        setCookieNoNetWorkTime(24 * 60 * 60 * 7);//无网缓存7天
    }


    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        HashMap<String, Object> map = new HashMap<>();

        map.put("likeName", getLikeName());
        map.put("gprsX", getGprsX());
        map.put("gprsY", getGprsY());
        map.put("page", getPage());
        map.put("size", getSize());
        return service.getSearchStoreList(map);
    }
}
